package com.mvp.refresh;

import android.content.Context;
import android.util.AttributeSet;

import com.scwang.smartrefresh.header.MaterialHeader;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

/**
 * 这个刷新库可能存在空指针异常,所以最好判断一下
 */
public class AutoRefreshLayout extends SmartRefreshLayout {
    public AutoRefreshLayout(Context context) {
        super(context);
        init();
    }

    public AutoRefreshLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public AutoRefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        setRefreshHeader(new MaterialHeader(getContext()));
    }

    public void finishRefreshAndLoadmore() {
        finishLoadMore();
        finishRefresh();
    }

}
